<?php

namespace app\model;

use app\Api;
use think\Db;

class AdminImages extends Common
{
    private static $obj = null;

    private $db_name = 'admin_images';

    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 类入口
     * @return AdminImages|null
     */
    public static function getInstance()
    {
        if (is_null(self::$obj))
            self::$obj = new self();
        return self::$obj;
    }

    public function toCount($arr_where)
    {
        return (int)Db::name($this->db_name)->where($arr_where)->count();
    }

    /**
     * 添加一条记录
     * @param $arr_data
     */
    public function toAdd($arr_data)
    {
        Db::name($this->db_name)->insert($arr_data);
        return (int)Db::name($this->db_name)->getLastInsID();
    }

    public function getValue($arr_where, $str_key)
    {
        return Db::name($this->db_name)->where($arr_where)->value($str_key);
    }
}
